package edu.ynu.se.xiecheng.achitectureclass.service;

import edu.ynu.se.xiecheng.achitectureclass.common.service.LogicService;
import edu.ynu.se.xiecheng.achitectureclass.dao.DeviceDao;
import edu.ynu.se.xiecheng.achitectureclass.dao.StatisticDao;
import edu.ynu.se.xiecheng.achitectureclass.entity.Device;
import edu.ynu.se.xiecheng.achitectureclass.entity.Statistic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StatisticService extends LogicService<StatisticDao, Statistic, Long> {

    @Autowired
    private DeviceDao deviceDao;

    public StatisticService(@Autowired StatisticDao dao) {
        super(dao);
    }

    public List<Statistic> getStatisticsByDevice(String deviceNumber) {
        Device device = deviceDao.getDeviceByDeviceNumber(deviceNumber);
        return dao.getStatisticsByDeviceIdIs(device.getId());
    }

}
